﻿using System;
using System.Collections.Generic;
using System.Text;


namespace Water.Architecture2.IDAL
{
    [Serializable]
    public struct WhereField
    {
        string name;
        /// <summary>
        /// 字段名
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        object value;
        /// <summary>
        /// 字段值
        /// </summary>
        public object Value
        {
            get { return this.value; }
            set { this.value = value; }
        }
        bool isOperator ;
        /// <summary>
        /// OperatorOrWhereClause属性 是否为Operator,true:Operator ,false:WhereClause
        /// </summary>
        public bool IsOperator
        {
            get { return isOperator; }
            set { isOperator = value; }
        }

        OperatorType _operator;
        /// <summary>
        /// 操作符(数据库运算符)
        /// </summary>
        public OperatorType Operator
        {
            get { return _operator; }
            set { _operator = value; }
        }
        string whereClause;
        /// <summary>
        /// where子句
        /// </summary>
        public string WhereClause
        {
            get { return whereClause; }
            set { whereClause = value; }
        }


        /*
        public WhereField(string name, object value, string operator_flag, bool isOperator)
        {
            this.name = name;
            this.value = value;
            this.operatorOrWhereClause = operator_flag;
            this.isOperator = isOperator;
        }
        */

        bool ignoreCase;

        /// <summary>
        /// 是否忽略大小写，默认false 不忽略大小写
        /// </summary>
        public bool IgnoreCase
        {
            get { return ignoreCase; }
            set { ignoreCase = value; }
        }
        public WhereField(string name, object value, OperatorType _operator, bool ignoreCase)
        {
            this.name = name;
            this.value = value;
            this._operator = _operator;
            this.whereClause = string.Empty;
            this.isOperator = true;
            this.ignoreCase = ignoreCase;
        }
        public WhereField(string name, object value,OperatorType _operator )
        {
            this.name = name;
            this.value = value;
            this._operator = _operator;
            this.whereClause = string.Empty;
            this.isOperator = true;
            this.ignoreCase = false;
        }
        public WhereField(string whereClause)
        {
            this.name = string.Empty;
            this.value = null;
            this._operator = OperatorType.Equals;
            this.whereClause = whereClause;
            this.isOperator = false;
            this.ignoreCase = false;
        } 

    }
}